package de.tum.in.eist.poll.shared.beans;

import java.io.Serializable;

import de.tum.in.eist.poll.client.views.widgets.questions.QuestionSingleChoiceWidget;
import de.tum.in.eist.poll.client.views.widgets.questions.QuestionWidget;

/**
 * A SingleChoiceQuestion is a Question which asks the User
 * for one (or no) choice of a range of choices. Each choice
 * consists simply of a String, which describes it.
 * 
 * @author The EIST-POLL-21 team.
 *
 */
public final class SingleChoiceQuestion extends Question implements Serializable {

	/**
	 * serialization version 
	 */
	private static final long serialVersionUID = 1L;
	
	private String[] choices;
	
	/**
	 * Dummy constructor for GWT. Never ever use this.
	 */
	public SingleChoiceQuestion() {
		super();
		choices = new String[0];
	}
	
	/**
	 * @param description see {@link Question}
	 * @param optional    see {@link Question}
	 * @param choices     Array of choices to choose from. The choice will be stored as an index of that array.
	 */
	public SingleChoiceQuestion(String description,	boolean optional, String[] choices) {
		super(description, optional);
		this.choices = choices;
	}

	/**
	 * @return the choices
	 */
	public String[] getChoices() {
		return choices;
	}
	
	/* (non-Javadoc)
	 * @see de.tum.in.eist.poll.shared.beans.Question#getWidget()
	 */
	@Override
	public QuestionWidget getWidget() {
		return new QuestionSingleChoiceWidget(this);
	}
}
